﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimpleRest.Core.Extensions.Documentation
{
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
    public class ParameterDescriptionAttribute : Attribute
    {
        public ParameterDescriptionAttribute(string name, Type type, bool isOptional)
        {
            this.Name = name;
            this.Type = type;
            this.IsOptional = isOptional;
        }
        public ParameterDescriptionAttribute(string name, Type type, bool isOptional, string description)
            : this(name, type, isOptional)
        {
            this.Description = description;
        }

        public string Name { get; set; }
        public Type Type { get; set; }
        public string Description { get; set; }
        public bool IsOptional { get; set; }

        public Parameter GetParameter()
        {
            return new Parameter()
            {
                Name = this.Name,
                Description = this.Description,
                IsOptional = this.IsOptional,
                Type = SimpleRest.Serialization.XsdSerializer.GetTypeName(this.Type)
            };
        }
    }
}
